package com.chen.facemanager.controller;


import com.chen.facemanager.service.impl.ALiserviceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;

@RestController
@RequestMapping("/alipay")
public class AlipayController {
    @Autowired
    ALiserviceImpl aLiservice;

    /**
     * 支付
     */
    @PostMapping("/apppay")
    public Map pay( @RequestParam(value = "orderId") String orderId,
                    @RequestParam(value = "uid") String uid,
                    @RequestParam(value = "hid") String hid,
                    @RequestParam(value = "totalFee") String totalFee,
                    @RequestParam(value = "htype") String htype) throws Exception {
        return aLiservice.pay(orderId,uid,hid,totalFee,htype);
    }

    /**
     * 回调
     * @param request
     * @param response
     * @return
     */
    @PostMapping("/alipayNotify")
    public void alipayNotify(HttpServletRequest request, HttpServletResponse response) {
        aLiservice.paymentCallback(request,response);
    }

}
